package com.jilian.powerstation.modul.activity;

import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;

import com.jilian.powerstation.R;
import com.jilian.powerstation.base.BaseActivity;

public class AboutActivity extends BaseActivity {
    private TextView mTvWebsite;
    private TextView mTvPrivacy;
    private TextView tvVersion;

    @Override
    protected void createViewModel() {

    }
    @Override
    public int intiLayout() {
        return R.layout.activity_about;
    }

    @Override
    public void initView() {
        setNormalTitle("About", v -> finish());
        mTvWebsite = findViewById(R.id.tv_website);
        mTvPrivacy = findViewById(R.id.tv_privacy);
        tvVersion = (TextView) findViewById(R.id.tv_version);
    }

    @Override
    public void initData() {
        PackageManager pm = getPackageManager();
        PackageInfo packageInfo = null;
        try {
            packageInfo = pm.getPackageInfo(getPackageName(), 0);
            String versionname = packageInfo.versionName;
            tvVersion.setText(versionname);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }


    }

    @Override
    public void initListener() {
        mTvWebsite.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(AboutActivity.this, WebViewActivity.class);
                intent.putExtra("linkUrl", "http://www.sunwodaenergy.com/index_en.aspx");
                startActivity(intent);
            }
        });
        mTvPrivacy.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(AboutActivity.this, WebViewActivity.class);
                intent.putExtra("linkUrl", "http://www.sunwodaenergy.com/index_en.aspx");
                startActivity(intent);
            }
        });
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        return super.dispatchTouchEvent(ev);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        return super.onTouchEvent(event);
    }
}
